package ypmits.components.util {
	import ypmits.bitmap.BitmapModifierTool;

	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.display.Sprite;

	/**
	 * @author Dave Lenz
	 */
	public class GrabThumbRoughner extends Sprite {

		/**
		 * This little baby is a simple one.
		 * It draws the rough part of a draggable object
		 * so it looks like it has a... well... 'a rough part'...
		 * for your thumb... or another finger
		 */
		public function GrabThumbRoughner( width : int = 11, height : int = 3, color : uint = 0xFFFFFF, useshadow : Boolean = false )
		{
			draw( width, height, color, useshadow );
			
			mouseEnabled = false;
		}

		
		
		private function draw( width : int, height : int, color : uint, useshadow : Boolean = false ) : void 
		{
			var shape : Shape = new Shape( );
			shape.graphics.beginFill( color );
			shape.graphics.drawRect( 0, 0, 1, 1 );
			shape.graphics.drawRect( 1, 2, 1, 1 );
			shape.graphics.endFill( );
			if( useshadow ) {
				shape.graphics.beginFill( 0, .6 );
				shape.graphics.drawRect( 0, 1, 1, 1 );
				shape.graphics.drawRect( 1, 3, 1, 1 );
			}

			var bitmap : Bitmap = BitmapModifierTool.convertToBitmap( shape, shape.width, shape.height, false );

			graphics.beginBitmapFill( bitmap.bitmapData, null, true, false );
			graphics.drawRect( 0, 0, width, height );
			graphics.endFill( );
		}
	}
}
